#ifndef __W25QXX_H
#define __W25QXX_H			    
#include "common.h"  

//////////////////////////////////////////////////////////////////////////////////	 

//W25Q series chip ID list  
#define W25Q08 	0XEF13 	
#define W25Q16 	0XEF14
#define W25Q32 	0XEF15
#define W25Q64 	0XEF16
#define W25Q128	0XEF17

//Instruction list
#define W25X_CMD_WriteEnable		  0x06 
#define W25X_CMD_WriteDisable		  0x04 
#define W25X_CMD_ReadStatusReg		0x05 
#define W25X_CMD_WriteStatusReg		0x01 
#define W25X_CMD_ReadData			    0x03 
#define W25X_CMD_FastReadData		  0x0B 
#define W25X_CMD_FastReadDual		  0x3B 
#define W25X_CMD_PageProgram		  0x02 
#define W25X_CMD_BlockErase			  0xD8 
#define W25X_CMD_SectorErase		  0x20 
#define W25X_CMD_ChipErase			  0xC7 
#define W25X_CMD_PowerDown			  0xB9 
#define W25X_CMD_ReleasePowerDown	0xAB 
#define W25X_CMD_DeviceID			    0xAB 
#define W25X_CMD_ManufactDeviceID	0x90 
#define W25X_CMD_JedecDeviceID		0x9F 

extern u16 W25QXX_ID;			  		   

#define	W25QXX_CS PBout(14)   

void W25QXX_Init(void);
u16  W25QXX_ReadID(void);  	    		//Read FLASH ID
u8	 W25QXX_ReadSR(void);        		//Read status register 
void W25QXX_Write_SR(u8 sr);  			//Write status register
void W25QXX_Write_Enable(void);  		//Write enable 
void W25QXX_Write_Disable(void);		//Write protection

void W25QXX_Erase_Chip(void);    	  	    //Whole chip erase
void W25QXX_Erase_Sector(u32 First_Addr);	//Sector erase
void W25QXX_Wait_Busy(void);            	//Wait for idle
void W25QXX_PowerDown(void);        	    //Enter power-down mode
void W25QXX_WAKEUP(void);				    //Wake up

void W25QXX_Read(u8* DataBuffer,u32 StartAddress,u16 ByteCount);      //Read the specified number of bytes from the specified address
void W25QXX_Write_Page(u8* DataBuffer,u32 StartAddress,u16 ByteCount);

void W25QXX_PageWrite(u8* pBuffer,u32 WriteAddr,u16 NumByteToWrite);  //Write to Flash by page
void W25QXX_SectorWrite(u8* pBuffer,u32 WriteAddr,u16 NumByteToWrite);//Write to Flash by sector
#endif
















